import { defineStore } from 'pinia'
//import { getConfig } from '@/api/app'
import $H from '@/common/js/request.js';

interface AppSate {
	config : Record<string, any>
}
export const useAppStore = defineStore({
	id: 'appStore',
	state: () : AppSate => ({
		config: {}
	}),
	getters: {
		getTabbarConfig: (state) => state.config.tabbar || [],
		getStyleConfig: (state) => state.config.style || {},

	},
	actions: {
		getImageUrl(url : string) {
			return url.indexOf('http') ? `${this.config.domain}${url}` : url
		},
		async getConfig() {
			const res = await $H.post('index/config', {
			}, {
				token: true
			});
			this.config = res.data
		}
	}
})